package com.pv.user.controller;

import com.pv.common.to.user.User;
import com.pv.common.utils.R;
import com.pv.common.utils.UserUtil;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.pv.user.entity.UserAuthorizeEntity;
import com.pv.user.service.UserAuthorizeService;



/**
 * 第三方用户授权信息
 *
 * @author zk
 * @email 2638561747@qq.com
 * @date 2021-08-21 14:35:31
 */
@RestController
@RequestMapping("user/userauthorize")
public class UserAuthorizeController {
    @Autowired
    private UserAuthorizeService userAuthorizeService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    @ApiOperation(value="查询全部",httpMethod="POST")
    public R list(@RequestBody UserAuthorizeEntity userAuthorize){
        User user = UserUtil.getUser();
//        PageUtils page = userAuthorizeService.queryPage(userAuthorize);
        return R.ok().put("page", null);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    @ApiOperation(value="根据主键查询", notes="参数只用到了主键." ,httpMethod="POST")
    public R info(@PathVariable("id") Integer id){
		UserAuthorizeEntity userAuthorize = userAuthorizeService.getById(id);
        return R.ok().put("userAuthorize", userAuthorize);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @ApiOperation(value="添加", notes="" ,httpMethod="POST")
    public R save(@RequestBody UserAuthorizeEntity userAuthorize){
		userAuthorizeService.save(userAuthorize);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @ApiOperation(value="修改", notes="" ,httpMethod="POST")
    public R update(@RequestBody UserAuthorizeEntity userAuthorize){
		userAuthorizeService.updateById(userAuthorize);

        return R.ok();
    }


}
